﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import flash.events.*;
    import org.aswing.event.*;

    public class DefaultBoundedRangeModel extends EventDispatcher implements BoundedRangeModel {

        private var value:int;
        private var extent:int;
        private var min:int;
        private var max:int;
        private var isAdjusting:Boolean;

        public function DefaultBoundedRangeModel(_arg1:int=0, _arg2:int=0, _arg3:int=0, _arg4:int=100){
            this.isAdjusting = false;
            if ((((((((_arg4 >= _arg3)) && ((_arg1 >= _arg3)))) && (((_arg1 + _arg2) >= _arg1)))) && (((_arg1 + _arg2) <= _arg4)))){
                this.value = _arg1;
                this.extent = _arg2;
                this.min = _arg3;
                this.max = _arg4;
            } else {
                throw (new RangeError("invalid range properties"));
            };
        }
        public function getValue():int{
            return (this.value);
        }
        public function getExtent():int{
            return (this.extent);
        }
        public function getMinimum():int{
            return (this.min);
        }
        public function getMaximum():int{
            return (this.max);
        }
        public function setValue(_arg1:int, _arg2:Boolean=true):void{
            _arg1 = Math.min(_arg1, (this.max - this.extent));
            var _local3:int = Math.max(_arg1, this.min);
            this.setRangeProperties(_local3, this.extent, this.min, this.max, this.isAdjusting, _arg2);
        }
        public function setExtent(_arg1:int):void{
            var _local2:int = Math.max(0, _arg1);
            if ((this.value + _local2) > this.max){
                _local2 = (this.max - this.value);
            };
            this.setRangeProperties(this.value, _local2, this.min, this.max, this.isAdjusting);
        }
        public function setMinimum(_arg1:int):void{
            var _local2:int = Math.max(_arg1, this.max);
            var _local3:int = Math.max(_arg1, this.value);
            var _local4:int = Math.min((_local2 - _local3), this.extent);
            this.setRangeProperties(_local3, _local4, _arg1, _local2, this.isAdjusting);
        }
        public function setMaximum(_arg1:int):void{
            var _local2:int = Math.min(_arg1, this.min);
            var _local3:int = Math.min((_arg1 - _local2), this.extent);
            var _local4:int = Math.min((_arg1 - _local3), this.value);
            this.setRangeProperties(_local4, _local3, _local2, _arg1, this.isAdjusting);
        }
        public function setValueIsAdjusting(_arg1:Boolean):void{
            this.setRangeProperties(this.value, this.extent, this.min, this.max, _arg1, false);
        }
        public function getValueIsAdjusting():Boolean{
            return (this.isAdjusting);
        }
        public function setRangeProperties(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:Boolean, _arg6:Boolean=true):void{
            if (_arg3 > _arg4){
                _arg3 = _arg4;
            };
            if (_arg1 > _arg4){
                _arg4 = _arg1;
            };
            if (_arg1 < _arg3){
                _arg3 = _arg1;
            };
            if ((_arg2 + _arg1) > _arg4){
                _arg2 = (_arg4 - _arg1);
            };
            if (_arg2 < 0){
                _arg2 = 0;
            };
            var _local7:Boolean = ((((((((!((_arg1 == this.value))) || (!((_arg2 == this.extent))))) || (!((_arg3 == this.min))))) || (!((_arg4 == this.max))))) || (!((_arg5 == this.isAdjusting))));
            if (_local7){
                this.value = _arg1;
                this.extent = _arg2;
                this.min = _arg3;
                this.max = _arg4;
                this.isAdjusting = _arg5;
                this.fireStateChanged(_arg6);
            };
        }
        public function addStateListener(_arg1:Function, _arg2:int=0, _arg3:Boolean=false):void{
            addEventListener(InteractiveEvent.STATE_CHANGED, _arg1, false, _arg2);
        }
        public function removeStateListener(_arg1:Function):void{
            removeEventListener(InteractiveEvent.STATE_CHANGED, _arg1);
        }
        protected function fireStateChanged(_arg1:Boolean):void{
            dispatchEvent(new InteractiveEvent(InteractiveEvent.STATE_CHANGED, _arg1));
        }
        override public function toString():String{
            var _local1:String = ((((((((((((("value=" + this.getValue()) + ", ") + "extent=") + this.getExtent()) + ", ") + "min=") + this.getMinimum()) + ", ") + "max=") + this.getMaximum()) + ", ") + "adj=") + this.getValueIsAdjusting());
            return (((("DefaultBoundedRangeModel" + "[") + _local1) + "]"));
        }

    }
}//package org.aswing 
